-
Notifications
You must be signed in to change notification settings - Fork 140
improve example test by sorting output #1366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve example test by sorting output #1366
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted filesContinue to review full report in Codecov by Sentry.
|
} | ||
} | ||
sort.Slice(activities, func(i, j int) bool { | ||
return strings.Compare(strings.ToLower(activities[i].Info.ActivityType), strings.ToLower(activities[j].Info.ActivityType)) < 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorting makes perfect sense, but there's no reason to ToLower
here afaict. It'll just make things more ambiguous than they are IRL, where strings need to be identical in both workers and example-test output checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the docs on strings.Compare
it looks like we can/probably should just use <
here... but they appear to be semantically identical so I'll stamp now and land whichever you prefer :) thankfully it's not a locale-sensitive comparison at least.
I saw the last comment after merging. Followed up in #1367 |
* improve example test by sorting output * replace slices pkg with sort * address comments
What changed?
Improving the example test by sorting the activities returned by Stats()
The example implementation range over a map and return the result in a slice. Because of this, the assertion against expected result would not always pass since the order is random. This made the test flaky
Why?
How did you test it?
unit tests
Potential risks